var _inherit = require('core/inherit.js');

function ScreenAdapter(camera) {
    this.mCamera = camera;
    this.mScreenWidth = 1;
    this.mScreenHeight = 1;
    this.mWidth = 1;
    this.mHeight = 1;
}
ScreenAdapter.prototype.onSizeChange = function (swidth, sheight) {
    this.mScreenWidth = swidth;
    this.mScreenHeight = sheight;
};

/**
 * fix size
 *
 * @param camera
 * @param height
 * @constructor
 */
function FixHeightAdapter(camera, height) {
    ScreenAdapter.call(this, camera);
    this.mFixHeight = height;
}
_inherit(FixHeightAdapter, ScreenAdapter);
FixHeightAdapter.prototype.onSizeChange = function (swidth, sheight) {
    ScreenAdapter.prototype.onSizeChange.apply(this, arguments);
    this.mHeight = this.mFixHeight;
    this.mWidth = swidth / sheight * this.mFixHeight;

    var camera = this.mCamera;
    camera.lookAt([0, 0, 10], [0, 0, 0], [0, 1, 0]).ortho(0, this.mWidth, 0, this.mHeight, 9, 11);
    camera.setViewport(this.mScreenWidth, this.mScreenHeight);
    camera.viewport();
};

exports.ScreenAdapter = ScreenAdapter;
exports.FixHeightAdapter = FixHeightAdapter;